package com.example.demo.service.Impl;


import com.example.demo.dao.IOb;
import com.example.demo.model.Ob;
import com.example.demo.service.IObService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator 董婷
 */

@Service
public class ObServiceImpl implements IObService{

    @Autowired
    private IOb obMapper;
    @Override
    public int insertOb(Ob ob){
        int obValue=0;

       Ob ob1=new Ob();
        ob1.setObid(ob.getObid());
        List<Ob> getO=obMapper.getAllOb(ob1);
        if(getO.size()>0){
            obValue=-1;

        }else{
            obValue=obMapper.insertOb(ob);
        }

        return obValue;
    }

    @Override
    public List<Ob> getAllOb(Ob ob) {


        return obMapper.getAllOb(ob);
    }

    @Override
    public int updateOb(Ob ob) {
        int obValues=0;
        if(ob.getObid()!=0){



            obValues=obMapper.updateOb(ob);
        }
        return obValues;
    }

    @Override
    public int deleteOb(Ob ob) {
        int obValues=0;
        if(ob.getObid()!=0)
        {
            //主键是否与其他表有关联

           obValues=obMapper.deleteOb(ob);
        }
        return obValues;
    }

    @Override
    public Ob getOb(Ob ob) {
        Ob ob1=new Ob();
        if(ob.getObid()!=0){
            ob1=obMapper.getOb(ob);
        }
        return ob1;
    }

}
